<!--{template admin/header}-->
<script src="./js/date/WdatePicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
  function chooseType(id){
	var ids = {'html':'html','word':'word','pic':'pic'};
	for (var i in ids) {
		if(ids[i] == id){
			$("#type_"+ids[i]).show();
		}else {
			$("#type_"+ids[i]).hide();
		}
	}
  }
  $(document).ready(function(){
	var type=document.getElementsByName('type');
	for (var i = 0;i<type.length;i++) {
		if (type[i].checked) {
			chooseType(type[i].id);
		}
	}
  });
</script>
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
  <tr>
    <td>
      <a href="nanbo.php?mod=income">广告管理</a>&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp;
      <a href="nanbo.php?mod=income&code=ad_list&op=$location">广告列表-&nbsp;&nbsp;{$ADLocationName}</a>&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp;添加/修改广告
    </td>
  </tr>
</table>

<form method="post" action="nanbo.php?mod=income&code=doAdd&location={$location}" enctype="multipart/form-data">
  <table  cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
    <tbody>
    <tr class="header">
      <td colspan="2"width="30%">添加广告</td>
    </tr>
    <tr>
      <td class="altbg1" width="30%">广告标题(必填):</td>
      <td class="altbg2"><input type="text" name="title" value={$ad_info['title']}></td>
    </tr>
    <tr>
      <td class="altbg1">广告投放范围(必选):</td>
      <td class="altbg2">
        <!--{loop $page_list $mod $val}-->
        <label><input type="checkbox" name="hcode[page][]" value="{$mod}" {$sel_checked[$mod]}>{$val}</label>
        <!--{/loop}-->
        <!--<input type="checkbox" name="page[]" value="addmore"><input type="text" name="addmore" value="">-->
      </td>
    </tr>
    <tr>
      <td class="altbg1">广告起始时间(选填):<br>设置广告起始生效的时间，格式 yyyy-mm-dd，留空为不限制起始时间</td>
      <td class="altbg2">
        <input type="text" name="ftime" value="{$ftime}" readonly onFocus="WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"/>
      </td>
    </tr>
    <tr>
      <td class="altbg1">广告结束时间(选填):<br>设置广告结束的时间，格式 yyyy-mm-dd，留空为不限制结束时间</td>
      <td class="altbg2">
	 	 <input type="text" name="ttime" value="{$ttime}" readonly onFocus="WdatePicker({startDate:'%y-%M-%d 00:00:00',dateFmt:'yyyy-MM-dd HH:mm',alwaysUseStartDate:true})"/>
	  </td>
    </tr>
    <tr>
      <td class="altbg1">展现方式(必填):</td>
      <td class="altbg2">
        <label><input type="radio" id="html" name="type" value=1 onclick="chooseType('html');" {eval if(!$ad_info['type'] ||$ad_info['type']==1) echo "checked"}>代码</label>
        <label><input type="radio" id="word" name="type" value=2 onclick="chooseType('word');" {eval if($ad_info['type']==2) echo "checked"}>文字</label>
        <label><input type="radio" id="pic" name="type" value=3 onclick="chooseType('pic');"  {eval if($ad_info['type']==3) echo "checked"}>图片</label>
      </td>
    </tr>
    </tbody>
    <tbody id="type_html" style="display:none">
      <tr>
        <td class="altbg1">广告HTML代码(必填):</td>
        <td class="altbg2"><textarea cols="50" name="hcode[html]" rows="6">{$hcode['html']}</textarea></td>
      </tr>
    </tbody>
    <tbody id="type_word" style="display:none">
      <tr>
        <td class="altbg1">文字内容(必填):<br>请输入文字广告的显示内容</td>
        <td class="altbg2"><textarea cols="50" name="hcode[word]" rows="6">{$hcode['word']}</textarea></td>
      </tr>
      <tr>
        <td class="altbg1">文字链接(必填):<br>请输入文字广告指向的 URL 链接地址。注意：站外的地址必须以http://开头</td>
        <td class="altbg2"><input type="text" name="hcode[word_url]" value="{$hcode['word_url']}"></td>
      </tr>
      <tr>
        <td class="altbg1">文字大小(选填):<br>请输入文字广告的内容显示字体，单位是PX</td>
        <td class="altbg2"><input type="text" name="hcode[word_size]" value="{$hcode['word_size']}"></td>
      </tr>
    </tbody>
    <tbody id="type_pic" style="display:none">
      <tr>
        <td class="altbg1">图片地址(必填):</td>
        <td class="altbg2">
          <input type="file" name="image">
            <!--{if $hcode['image']}-->
            <br><img src="$hcode['image']" width="75px" height="75px">
      		<!--{/if}-->
        </td>
      </tr>
      <tr>
        <td class="altbg1">图片链接(必填):</td>
        <td class="altbg2"><input type="text" name="hcode[pic_url]" value="{$hcode['pic_url']}"></td>
      </tr>
      <tr>
        <td class="altbg1">图片替换文字(选填):</td>
        <td class="altbg2"><input type="text" name="hcode[pic_title]" value="{$hcode['pic_title']}"></td>
      </tr>
      <tr>
        <td class="altbg1">图片宽度(选填):<br>图片推荐大小:{$AdLocationList[$location]['width']}</td>
        <td class="altbg2"><input type="text" name="hcode[pic_width]" value="{$hcode['pic_width']}"></td>
      </tr>
      <tr>
        <td class="altbg1">图片高度(选填):<br>图片推荐大小:{$AdLocationList[$location]['height']}</td>
        <td class="altbg2"><input type="text" name="hcode[pic_height]" value="{$hcode['pic_height']}"></td>
      </tr>
    </tbody>
  </table>
  <center>
    <input type="submit" class="button" value="提交">
    <input type="hidden" name="adid" value="{$adid}">
  </center>
</form>